//
//  PokerTexasHoldem_Client.m
//  CPokerTexasHoldem_Client
//
//  Created by Enric Vergara Carreras on 04/01/12.
//  Copyright empresa 2012. All rights reserved.
//


// Import the interfaces
#import "PokerTexasHoldem_Client.h"

// CPokerTexasHoldem_Client implementation
@implementation CPokerTexasHoldem_Client

+(CCScene *) scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	CPokerTexasHoldem_Client *layer = [CPokerTexasHoldem_Client node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init]))
    {
		
        m_pNetwork = [CNetwork new];
        [m_pNetwork setClient:self];
        
        [CCMenuItemFont setFontName:@"Arial"];
        [CCMenuItemFont setFontSize:40];
        
        button_Connect  = [CCMenuItemFont itemFromString:@"connect" target:self selector:@selector(menuConnect:)];
        menu = [CCMenu menuWithItems:button_Connect,nil];
        menu.position = CGPointMake(300, 200);
        [self addChild:menu];
        menu.visible = true;
        
        m_PokerMenu = [CPokerMenu node];
        [self addChild:m_PokerMenu];
        m_PokerMenu.position = CGPointMake(220, 70);
        m_PokerMenu.visible = false;

	}
	return self;
}

- (void) menuConnect: (id) sender
{
    if (!m_bConnected)
    {
        [m_pNetwork connectClicked];
    }
}

- (void) connectOk
{
    menu.visible = false;
    m_bConnected = true;
    m_PokerMenu.visible = true;    
}

-(void) setHoleCards:(unsigned int)right LeftCard:(unsigned int) left
{
    [m_PokerMenu setHoleCards:right LeftCard:left];
    [m_PokerMenu showCards];
}

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
}
@end
